
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-- 文件管理
----------------------------------------------------------------------- 
----------------------------------------------------------------------- 
DROP TABLE h_file_user;
CREATE TABLE h_file_user (
  id	 	int 	NOT NULL,
  userid	int		NOT NULL,
  upvol 	int		default 2 not null,		/* 默认每次附件最大2M */
  allvol 	int		default 50 not null,	/* 默认总容量最大2M */
  demo 		varchar2(200) 	,
  PRIMARY KEY (id)
);

-- 序列
create sequence h_file_user_seq start with 1 increment by 1;
create or replace trigger h_file_user_auto
  before insert on h_file_user
  for each row
begin
  select h_file_user_seq.nextval into :new.id from dual;
end;
/

create index h_file_user_u on h_file_user(userid);



DROP TABLE h_file_upload;
CREATE TABLE h_file_upload (
  id	 		int 			NOT NULL,
  userid		int				NOT NULL,
  filename 	varchar(100)		NOT NULL,
  filepath 	varchar(500)		NOT NULL,
  uptime 	date	 		default sysdate not null,
  sizes 	int				default 0 not null,/*K字节*/
  state		int 			default 0 not null,/* 0正常，1删除到垃圾箱*/
  PRIMARY KEY (id)
);
-- 序列
create sequence h_file_upload_seq start with 1 increment by 1;
create or replace trigger h_file_upload_auto
  before insert on h_file_upload
  for each row
begin
  select h_file_upload_seq.nextval into :new.id from dual;
end;
/

create index h_file_upload_u on h_file_upload(userid);